package com.lvyq.myplayer.model.history

import androidx.lifecycle.ViewModel
import com.lvyq.myplayer.dao.PlayHistoryDao
import kotlinx.coroutines.flow.Flow
/**
 * 文件描述：PlayHistoryViewModel
 * 作者：lvyq
 * 创建时间：2025-06-16
 * 修改时间：2025-06-16
 */
class PlayHistoryViewModel(private val playHistoryDao: PlayHistoryDao) : ViewModel() {

     fun getAllPlayHistoryListFlow(type: Int):Flow<List<PlayHistoryEntity> >{
       return playHistoryDao.getAllPlayHistoryListFlow(type)
    }

     suspend fun addPlayHistory(data: PlayHistoryEntity) {
         playHistoryDao.insertPlayHistory(data)
     }

    suspend fun deletePlayHistory(data: PlayHistoryEntity) {
        playHistoryDao.deletePlayHistory(data)
    }
    suspend fun deletePlayHistoryByIds(ids: List<Int>) {
        playHistoryDao.deleteByIds(ids)
    }

    suspend fun updatePlayHistory(data: PlayHistoryEntity){
        playHistoryDao.updatePlayHistory(data)
    }

    suspend fun getPlayHistoryByBusinessKeyAndType(businessKey:Int,type:Int):PlayHistoryEntity?{
       return playHistoryDao.getPlayHistoryByBusinessKeyAndType(businessKey,type)
    }
     fun count(type: Int):Flow<Long>{
       return playHistoryDao.count(type)
    }
    fun count():Flow<Long>{
        return playHistoryDao.count()
    }


}
